const MYSQL = require('mysql');
let options = {
    host: "localhost",
    port: "3306", //默认3306端口,可以不做配置
    user: "root",
    password: "123456", //台式 
    // password: "root", //笔记本
    database: "rinvay"
};
//查询语句封装

const query = (sql, para) => {
    return new Promise((resolve, reject) => {
        let conn = MYSQL.createConnection(options);
        conn.connect();
        conn.query(sql, para, (err, res) => {
            if (err) return reject(err);
            return resolve(res);
        })
        conn.end()
    })
}

module.exports = query;